package 最值算法.最大连续1的个数;

/**
 * TODO
 *
 * @className: zdlx1dgs
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-05-10 17:21
 **/
public class zdlx1dgs {
    public static void main(String[] args) {
        int[] nums = {1,1,0,1,1,1};
        System.out.println(findMaxConsecutiveOnes(nums));
    }
    public static  int findMaxConsecutiveOnes(int[] nums) {
        int count = 0;
        int max = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i]==1){
                ++count;
            }
            if (nums[i]==0){
                count = 0;
            }
            if (max < count){
                max = count;
            }
        }
        return max;
    }
}
